// MyColorDialog.cpp : implementation file
//

#include "stdafx.h"
#include "waveeditor.h"
#include "MyColorDialog.h"
#include "languagecomponents.h"


// MyColorDialog dialog

IMPLEMENT_DYNAMIC(MyColorDialog, CDialog)

BEGIN_MESSAGE_MAP(MyColorDialog, CDialog)
	ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()

MyColorDialog::MyColorDialog(CWnd* pParent /*=NULL*/)
	: CDialog(MyColorDialog::IDD, pParent)
{

}

MyColorDialog::~MyColorDialog()
{
}

void MyColorDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_COLOR_LIST, ColorList);

	CImageList *pImageList = new CImageList();
	pImageList->Create(IDB_COLORS_BITMAP, 16, 4, RGB(128,128,128));
	ColorList.SetImageList( pImageList, LVSIL_SMALL );
	for ( int i = 0; i < 9; i++ )
	{
		ColorList.InsertItem(i,"",i);
	}
}

void MyColorDialog::OnBnClickedOk()
{
	POSITION pos = ColorList.GetFirstSelectedItemPosition();
	if(pos != NULL)
	{
		switch ((int)pos)
		{
		case 1:
			{
				ChosenColor = DARK_RED;
				break;
			}
		case 2:
			{
				ChosenColor = DARK_GREEN;
				break;
			}
		case 3:
			{
				ChosenColor =	BROWN;
				break;
			}
		case 4:
			{
				ChosenColor = DARK_BLUE;
				break;
			}
		case 5:
			{
				ChosenColor = DARK_MAGENTA;
				break;
			}
		case 6:
			{
				ChosenColor = DARK_CYAN;
				break;
			}
		case 7:
			{
				ChosenColor = YELLOW;
				break;
			}
		case 8:
			{
				ChosenColor = MAGENTA;
				break;
			}
		case 9:
			{
				ChosenColor = WHITE;
				break;
			}
		default:
			{
				OnCancel();
			}
		}
		OnOK();
	}
	else
	{
		OnCancel();
	}
}




// MyColorDialog message handlers
